package com.ruoyi.kcnr.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.kcnr.domain.Kcpj;
import com.ruoyi.kcnr.domain.Kcyh;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.kcnr.domain.Kclb;
import com.ruoyi.kcnr.service.IKclbService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 *  课程内容列表Controller
 * 
 * @author ruoyi
 * @date 2024-08-06
 */
@RestController
@RequestMapping("/kclb")
public class KclbController extends BaseController
{
    @Autowired
    private IKclbService kclbService;

    /**
     * 查询 课程内容列表列表
     */
    @RequiresPermissions("kcnr:kclb:list")
    @GetMapping("/list")
    public TableDataInfo list(Kclb kclb)
    {
        startPage();
        List<Kclb> list = kclbService.selectKclbList(kclb);
        return getDataTable(list);
    }

    /**
     * 导出 课程内容列表列表
     */
    @RequiresPermissions("kcnr:kclb:export")
    @Log(title = " 课程内容列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Kclb kclb)
    {
        List<Kclb> list = kclbService.selectKclbList(kclb);
        ExcelUtil<Kclb> util = new ExcelUtil<Kclb>(Kclb.class);
        util.exportExcel(response, list, " 课程内容列表数据");
    }

    /**
     * 获取 课程内容列表详细信息
     */
    @RequiresPermissions("kcnr:kclb:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kclbService.selectKclbById(id));
    }

    /**
     * 新增 课程内容列表
     */
    @RequiresPermissions("kcnr:kclb:add")
    @Log(title = " 课程内容列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Kclb kclb)
    {
        return toAjax(kclbService.insertKclb(kclb));
    }

    /**
     * 修改 课程内容列表
     */
    @RequiresPermissions("kcnr:kclb:edit")
    @Log(title = " 课程内容列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public int edit(@RequestBody Kclb kclb)
    {
       return kclbService.updateKclb(kclb);
    }

    /**
     * 删除 课程内容列表
     */
    @RequiresPermissions("kcnr:kclb:remove")
    @Log(title = " 课程内容列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kclbService.deleteKclbByIds(ids));
    }

    @RequiresPermissions("kclb:kclb:kepjlist")
    @GetMapping("kcpjlist")
    public List<Kcyh> kcpjlist(Kcpj kcpj)
    {
        return kclbService.kcpjlist(kcpj);
    }
}
